import { _decorator, Component, director, Node,  v3, Widget } from 'cc';
import { Tools } from './Tools';
import { events } from './Enums';
import { gameMgr } from '../gameMgr';
import { TipsAction } from './TipsAction';
const { ccclass, property } = _decorator;

@ccclass('GameSetUp')
export class GameSetUp extends Component {
    
    @property([Node])
    music_kg:Node[]=[];
    @property([Node])
    sound_kg:Node[]=[];
    @property([Node])
    vibrate_kg:Node[]=[];

    @property(TipsAction)
    tipAct:TipsAction = null;

    start() {

    }

    
    onOpen(){
        Tools.updateWidget(this.node)
    }

    onClose(){
        this.node.getComponent(Widget).enabled = false;
        this.node.setPosition(v3(-1024 , 0 , 0 ));
    }

    onMusic_kg(e,data){
        let num:number = data;
        let b = num == 1 ? false : true;
        this.music_kg[1].active = b;
    }
    
    onSound_kg(e,data){
        let num:number = data;
        let b = num == 1 ? false : true;
        this.sound_kg[1].active = b;
    }
    
    onVibrate_kg(e,data){
        let num:number = data;
        let b = num == 1 ? false : true;
        this.vibrate_kg[1].active = b;
    }

    on_Tips(){
        //console.log('setup 重新开始')
        //gameMgr.Inst.on_restart_game();

        this.tipAct.on_open();

        this.onClose();
    }

    on_Restart(){
        console.log("重玩本关")
        gameMgr.Inst.on_restart_game();
    }

    onRetureHome(){
        gameMgr.Inst.on_goto_Home();
    }
}


